home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z9.ADF
/
Wormbench
/
Worms.mod
< prev
Wrap
Text File
|
1987-11-27
|
5KB
|
153 lines
MODULE Wormbench; (* Wormbench 1.0 for Benchmark Modula-2 *)
(*
Wormbench 1.0 - ] Mike SCARY Scalora [ - PLink : SCARY
This MODULE is public domain. Freely distributable as long as this
notice stays in.
This program was originally uploaded to PeopleLink's Amiga Zone. The
Amiga Zone has well over 3000 members, and a library of thousands of
public domain files. If you're interested in joining us, call
800-524-0100 (voice)
or 800-826-8855 (modem).
*)
FROM System IMPORT argv, argc;
FROM SYSTEM IMPORT ADR, ADDRESS, BYTE;
FROM Intuition IMPORT CloseScreen, ScreenPtr,
ScreenFlags, ScreenFlagsSet, ScreenToFront,
OpenWorkBench, CurrentTime,
ShowTitle;
FROM Drawing IMPORT DrawEllipse, SetWrMsk, SetAPen, SetDrMd;
FROM Blit IMPORT BltBitMap, MinTermFlagsSet;
FROM Views IMPORT LoadRGB4;
FROM Rasters IMPORT Jam1, Jam2;
FROM SimpleScreens IMPORT CreateScreen, ScreenOptFlags;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
FROM Terminal IMPORT WriteString;
FROM MathLib0 IMPORT real, entier, sin, cos, DegToRad,
MathTransName, MathTransBase;
FROM Libraries IMPORT OpenLibrary, CloseLibrary;
FROM Tasks IMPORT TaskPtr, FindTask;
VAR
WBScrn,
MyScrn : ScreenPtr;
MyTask : TaskPtr;
Colors : ARRAY [0..7] OF CARDINAL;
Worm : ARRAY [1..10] OF RECORD
dir : REAL;
x : ARRAY [1..20] OF INTEGER;
y : ARRAY [1..20] OF INTEGER;
END;
movex,
movey : REAL;
radx,
rady : INTEGER;
H,W,
WC,NW : CARDINAL;
NX,NY : INTEGER;
Secs,
Micros : LONGCARD;
PROCEDURE Halt;
BEGIN
IF MyScrn#NIL THEN CloseScreen(MyScrn^); END;
IF MathTransBase#NIL THEN CloseLibrary(MathTransBase^); END;
HALT;
END Halt;
BEGIN
MyTask := FindTask(NIL);
MyScrn := NIL;
MathTransBase := OpenLibrary(ADR(MathTransName), 0D);
IF MathTransBase=NIL THEN
WriteString("ERROR: 'mathtrans.library' not found!\n"); Halt; END;
WBScrn := OpenWorkBench();
IF WBScrn=NIL THEN WriteString('Could not get WB ScreenPtr!\n'); Halt; END;
Colors[0] := WBScrn^.ViewPort.ColorMap^.ColorTable^[0];
Colors[1] := WBScrn^.ViewPort.ColorMap^.ColorTable^[1];
Colors[2] := WBScrn^.ViewPort.ColorMap^.ColorTable^[2];
Colors[3] := WBScrn^.ViewPort.ColorMap^.ColorTable^[3];
Colors[4] := 0D74H; Colors[5] := 0D74H;
Colors[6] := 0D74H; Colors[7] := 0D74H;
ScreenOptFlags := ScreenFlagsSet{ScreenBehind};
IF WBScrn^.Height>320 THEN H := 400; ELSE H := 200; END;
MyScrn := CreateScreen(640,H,3,NIL);
IF MyScrn=NIL THEN WriteString('Could not open screen!\n'); Halt; END;
ShowTitle(MyScrn^,FALSE);
LoadRGB4(MyScrn^.ViewPort,ADR(Colors),8);
(*****************
MyWind := CreateWindow(0,0,640,H,IDCMPFlagsSet{},
WindowFlagsSet{BackDrop,Borderless,Activate},
NIL,MyScrn,NIL);
IF MyWind=NIL THEN WriteString('Could not open window!\n'); Halt; END;
******************)
WriteString('\nWormbench 1.0 - ] Mike SCARY Scalora [ -\n\n');
WriteString('TIUQ OT C-LRTC\n\n');
IF BltBitMap(WBScrn^.BitMap,0,0,
MyScrn^.BitMap,0,0,
640,INTEGER(H),
MinTermFlagsSet(0C0H),BYTE(03H),NIL)=0D THEN
WriteString('Error on BltBitMap!\n');
END;
NW := 5;
IF (argc>1) AND (argv^[1]^[0]>='0') AND (argv^[1]^[0]<='9') THEN
NW := ORD(argv^[1]^[0])-ORD('0'); END;
IF NW=0 THEN NW := 10; END;
movex := 8.0;
radx := 6;
IF H=400 THEN movey := 8.0; rady := 6;
ELSE movey := 4.0; rady := 3; END;
FOR W := 1 TO NW DO
Worm[W].dir := DegToRad(FLOAT(360 DIV NW * W));
FOR WC := 1 TO 20 DO
Worm[W].x[WC] := 320;
Worm[W].y[WC] := H DIV 2;
END;
END;
WC := 1;
ScreenToFront(MyScrn^);
SetWrMsk(MyScrn^.RastPort,BYTE(4));
SetDrMd(MyScrn^.RastPort,Jam1);
LOOP
IF 12 IN MyTask^.tcSigRecvd THEN EXIT; END;
FOR W := 1 TO NW DO
SetAPen(MyScrn^.RastPort,0);
DrawEllipse(MyScrn^.RastPort,Worm[W].x[WC]+10,
Worm[W].y[WC]+10,radx,rady);
CurrentTime(ADR(Secs),ADR(Micros));
IF 0 IN BITSET(Micros) THEN
Worm[W].dir := Worm[W].dir + 0.1475;
ELSE
Worm[W].dir := Worm[W].dir - 0.1475;
END;
IF WC=1 THEN NX := Worm[W].x[20]; NY := Worm[W].y[20];
ELSE NX := Worm[W].x[WC-1]; NY := Worm[W].y[WC-1]; END;
NX := NX + TRUNC(movex * cos(Worm[W].dir));
NY := NY + TRUNC(movey * sin(Worm[W].dir));
IF NX<0 THEN Worm[W].x[WC] := NX + 620;
ELSIF NX>619 THEN Worm[W].x[WC] := NX - 620;
ELSE Worm[W].x[WC] := NX; END;
IF NY<0 THEN Worm[W].y[WC] := NY + INTEGER(H-20);
ELSIF NY>=INTEGER(H-21) THEN Worm[W].y[WC] := NY - INTEGER(H-20);
ELSE Worm[W].y[WC] := NY; END;
SetAPen(MyScrn^.RastPort,4);
DrawEllipse(MyScrn^.RastPort,Worm[W].x[WC]+10,
Worm[W].y[WC]+10,radx,rady);
END;
WC := (WC MOD 20) + 1;
END;
Halt;
END Wormbench.